/**
 * 集模拟和调试功能于一身. 自动生成数据和增删查改一系列接口, 支持文件上传下载, 延迟, 自定义接口逻辑...
 * see https://www.hongqiye.com/doc/mockm/
 */

/** @type {import('mockm/@types/config').Config} */
module.exports = (util) => {
  const { libObj: { mockjs } } = util
  return {
    port: 9500,
    testPort: 9505,
    replayPort: 9501,
    proxy: {
      '/': `http://www.httpbin.org/`,
    },
    clearHistory: true,
    dbCover: true,
    db: mockjs.mock({
      'books|40-60': [
        {
          'id|+1': 1,
          user: /\d\d/,
          view: /\d\d\d\d/,
          'type|1': [`js`, `css`, `html`],
          'discount|1': [`0`, `1`],
          author: {
            'name|1': [`张三`, `李四`],
          },
          title: '@ctitle',
        }
      ],
    }),
    api: {
      '/post': {
        code: 0,
        data: {
          name: 'vue3'
        }
      },
      async '/text'(req, res) {
        res.json(req.body)
      },
      '/get'(req, res) {
        res.json({
          code: 0,
          data: {
            name: mockjs.mock(`@cname`),
            age: 60,
          },
        })
      },
    },
    static: [
      {
        path: `/assets`,
        fileDir: `./src/assets`,
      },
    ],
  }
}
